<% if @assistances.empty? %>
	<p>Nessuna assistenza</p>
<% else %>
<table>
  <tr>
		<th></th>
    <th>Cliente</th>
    <th>Stato</th>
    <th>Scadenza</th>
		<th>Creazione</th>
    <th colspan="4">Comandi</th>
  </tr>
<% for assistance in @assistances %>
	<% id = "quick_view" + assistance.id.to_s %>
	<tr class="<%= cycle("even", "odd") %>">
  	<% if assistance.urgency? %><td><%= image_tag("Urgent.gif", :alt => "tassativa") %></td><% else %><td></td><% end %>
    <td><%= assistance.client.name_or_society %></td>
    <td><%= image_tag(assistance.stato_to_image) %></td>
		<td><%= if assistance.scaduta? then "da " else "tra " end %><%= assistance.expiration_from_now %></td>
		<td><%= assistance.created_at.to_s(:short) %></td>
		<td style="position: relative">
			<a href="#" onclick="try { Effect.toggle('<%= id %>','appear',{duration:0.5}); new Draggable('<%= id %>'); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Effect.toggle(\'<%= id %>\',\'appear\',{duration:0.2});'); throw e }; return false;"><%= image_tag("eye.png", :alt => "quick view") %></a>
			<div id="<%= id %>" class="quick_view" style="display: none;">
				<b>Descrizione: </b><%= assistance.short_desc %><br />
				<b>Note: </b><%= assistance.notes %><br />
				<b>Valore: </b><%= assistance.token_to_s %><br />
				<b>Resoconto: </b><%= assistance.confirm_to_s %><br />
				<b>Progressione: </b><%= assistance.num_ass %>a assistenza<br />
				<b>Operazioni: </b><br />
					<ul><% for operation in assistance.operations do %>
						<li><%= operation.description %></li>
					<% end %></ul>
			</div>
		</td>
    <td><%= link_to image_tag("info.png", :alt => "show"), assistance %></td>
    <td><%= link_to image_tag("edit.png", :alt => "edit"), edit_assistance_path(assistance) %></td>
    <td><%= link_to image_tag("delete.png", :alt => "delete"), assistance, :confirm => 'Sei sicuro?', :method => :delete %></td>
  </tr>
<% end %>
</table>
<%= will_paginate @assistances, option = {:inner_window => 2, :outer_window => 3} %>
<% end %>